Skip to content

feat(changelog): warn when template uses remote variables without matching feature#1545

Open
arieleli01212 wants to merge 3 commits into
orhun:mainfrom
arieleli01212:warn-missing-remote-feature
Open

feat(changelog): warn when template uses remote variables without matching feature#1545
arieleli01212 wants to merge 3 commits into
orhun:mainfrom
arieleli01212:warn-missing-remote-feature

Conversation

@arieleli01212

Copy link
Copy Markdown

Fixes #659.

Problem

When a template references variables like github.contributors or commit.gitlab but the binary was compiled without the corresponding feature flag, the output is silently empty — no error, no warning, just missing data. This is confusing because the template looks correct but produces nothing for those fields.

Solution

Added a warn_if_remote_template_variables_without_feature function that is called from Changelog::build. It checks each template (header, body, footer) for remote-specific variable names and emits a tracing::warn when the relevant Cargo feature is absent.

The check uses the existing Template::contains_variable method and is gated with #[cfg(not(feature = "..."))] so there is zero overhead when the feature is enabled.

WARN git_cliff_core::changelog: Template uses a `github` variable (e.g. `github.contributors`) 
but the `github` feature is not enabled. Rebuild git-cliff with `--features github` or use a 
binary that includes all remote features.

All five remotes are covered: github, gitlab, gitea, bitbucket, azure_devops.

…ching feature

When a user's template references variables like `github.contributors`
or `commit.gitlab` but the binary was compiled without the corresponding
feature flag (`github`, `gitlab`, etc.), the rendering silently produces
empty output with no indication of why.

Add a `warn_if_remote_template_variables_without_feature` check in
`Changelog::build` that emits a `tracing::warn` for each remote whose
template variables are present but whose Cargo feature is absent.

Fixes orhun#659
@arieleli01212 arieleli01212 requested a review from orhun as a code owner May 27, 2026 16:04
@codecov-commenter

codecov-commenter commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.65%. Comparing base (772e01d) to head (7437964).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1545      +/-   ##
==========================================
- Coverage   48.65%   48.65%   -0.00%     
==========================================
  Files          26       26              
  Lines        2288     2284       -4     
==========================================
- Hits         1113     1111       -2     
+ Misses       1175     1173       -2     
Flag Coverage Δ
unit-tests 48.65% <100.00%> (-<0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…abled

The warn_if_remote_template_variables_without_feature function declared a
`templates` Vec that was only accessed inside cfg-gated blocks. When all
remote features are compiled in (the default build), every
`#[cfg(not(feature = "..."))]` condition is false, so `templates` is never
read — triggering an unused-variable error under `-D warnings`.

Restructure: move the templates array construction inline inside each
macro expansion. Each branch is self-contained and only compiled when the
corresponding feature is absent, so there is no unused variable in any
build configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not fail on unexisting GitHub/GitLab template variables

3 participants